package com.moon.game.message;

import java.io.Serializable;
import java.util.HashMap;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;


@SuppressWarnings("serial")
public class ObjMessage implements Serializable {
    public static final String STATUS_SUCC = "succ";
    public static final String STATUS_ERROR = "error"; // 逻辑错误
    public static final String STATUS_FAIL = "fail"; // 系统错误

    private String cmd = "UNKNOWN";
    private String status = "UNKNOWN";
    private String msg = "";
    private String sid;
	private String pid;
    private String ip;
    private String[] ps = null; // 参数
    private boolean isCheckSign = true; // 是否校验书签
    private HashMap<String, Object> data = new HashMap<String, Object>();
    private long startTime;
    private int respType = 0; // 应答的数据类型 0、html 1、json
    private boolean isReturn = true; // 是否有返回 true需要返回,false不需要返回

//    private ChargeNotify chargeNotify;// 腾讯输入密码购买回调post参数

    public ObjMessage() {
        this.status = STATUS_SUCC;
        this.msg = "";
    }

    public ObjMessage(String status) {
        this.status = status;
        this.msg = "";
    }

    public String getCmd() {
        return cmd;
    }

    public void setCmd(String cmd) {
        this.cmd = cmd;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getSid() {
		return sid;
	}
    
	public void setSid(String sid) {
		this.sid = sid;
	}
	
    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public void clear() {
        cmd = "UNKNOWN";
        status = "succ";
        msg = "";
        pid = "0";
        data.clear();
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public void setError() {
        this.status = STATUS_ERROR;
    }

    public HashMap<String, Object> getData() {
        return data;
    }

    public void setData(HashMap<String, Object> data) {
        this.data = data;
    }

    public void setText(String label, Object id) {
        data.put(label, String.valueOf(id));
    }

    public void setVO(String label, Object vo) {
        data.put(label, vo);
    }

    public Object getVO(String label) {
        return data.get(label);
    }

    public boolean isCheckSign() {
        return isCheckSign;
    }

    public void setCheckSign(boolean isCheckSign) {
        this.isCheckSign = isCheckSign;
    }

    public String[] getPs() {
        return ps;
    }

    public void setPs(String[] ps) {
        this.ps = ps;
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public int getRespType() {
        return respType;
    }

    public void setRespType(int respType) {
        this.respType = respType;
    }

    /**
     * @return the ip
     */
    public final String getIp() {
        return ip;
    }

    /**
     * @param ip
     *            the ip to set
     */
    public final void setIp(String ip) {
        this.ip = ip;
    }

    public boolean isReturn() {
        return isReturn;
    }

    public void setReturn(boolean isReturn) {
        this.isReturn = isReturn;
    }

    /**
     * @return the chargeNotify
     *//*
    public final ChargeNotify getChargeNotify() {
        return chargeNotify;
    }

    *//**
     * @param chargeNotify
     *            the chargeNotify to set
     *//*
    public final void setChargeNotify(ChargeNotify chargeNotify) {
        this.chargeNotify = chargeNotify;
    }*/

    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

}
